package org.point.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.point.common.dao.impl.BaseDaoImpl;
import org.point.common.util.DoPage;
import org.point.dao.ConvertRuleMainDao;import org.point.domain.ConvertRuleMain;
import org.springframework.stereotype.Repository;

/**
 * 
 * @ClassName: ConvertRuleMainDaoImpl
 * @Description: TODO(兑换规则主表实现类)
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午3:29:16
 *
 */
@Repository("convertRuleMainDao")
public class ConvertRuleMainDaoImpl extends BaseDaoImpl<ConvertRuleMain, Serializable> implements ConvertRuleMainDao {

	/**
	 * 利用反射，获取mapper.xml的namespace
	 * <p>Title: </p>  
	 * <p>Description: </p>
	 */
	public ConvertRuleMainDaoImpl() {
		namespace = super.getNamespace();
	}

	private final static String SQLID_FINDCRMFORCO = "find_crm_for_co";
	private final static String SQLID_COUNTCRMFORCO = "count_crm_form_co";
	private final static String SQLID_INSERTCRMFORCO = "insert_crm_for_co";
	private final static String SQLID_UPDSTATUS = "upd_status";
	private final static String SQLID_UPDDELFLAG = "upd_delflag";
	private static final String SQLID_SEARCHFORCRM = "searchForCRM";
	private static final String SQLID_DELCRMS = "delCrms";
	private static final String SQLID_DELCRMBYID = "delCrmByid";
	
	public List<ConvertRuleMain> findCRMForMem(DoPage<ConvertRuleMain> page) {
		List<ConvertRuleMain> records = null;
		try {
			records = getSqlSession().selectList(namespace + SQLID_FINDCRMFORCO, page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return records;
	}

	public Integer countCRMForMem(DoPage<ConvertRuleMain> page) {
		Integer result = 0;
		try {
			result = getSqlSession().selectOne(namespace + SQLID_COUNTCRMFORCO, page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public Integer insertCRMForMem(ConvertRuleMain record) {
		Integer result = 0;
		try {
			result = getSqlSession().insert(namespace + SQLID_INSERTCRMFORCO, record);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public Integer updStatus(Map<String, Object> map) {
		Integer result = 0;
		try {
			result = getSqlSession().update(namespace + SQLID_UPDSTATUS, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public Integer updDelflag(Map<String, Object> map) {
		Integer result = 0;
		try {
			result = getSqlSession().update(namespace + SQLID_UPDDELFLAG, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public ConvertRuleMain searchForCon(Map<String, Object> map) {
		ConvertRuleMain record = null;
		try {
			record = getSqlSession().selectOne(namespace + SQLID_SEARCHFORCRM, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return record;
	}

	public Integer deleteCrm(Map<String, Object> map) {
		Integer result = 0;
		try {
			result = getSqlSession().update(namespace + SQLID_DELCRMS, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public Integer delCRMbyId(Map<String, Object> map) {
		Integer result = 0;
		try {
			result = getSqlSession().update(namespace + SQLID_DELCRMBYID, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

}
